$(() => {
    layui.use(() => {
        let laydate = layui.laydate;
        laydate.render({
            elem: "#birthday"
        });
    });
});

//保存员工
function save(cb) {
    let name = $("#name").val();
    let pinyin = $("#pinyin").val();
    let sex = $(":radio[name=sex]:checked").val();
    let birthday = $("#birthday").val();
    let phone = $("#phone").val();
    let email = $("#email").val();
    let cardId = $("#cardId").val();
    let description = $("#description").val();

    //向后台发出ajax请求，微服务
    let url = "/api/v1/employee";
    $.ajax({
        url,
        method: "post",
        dataType: "json",
        data: {
            name, pinyin, sex, birthday, phone, email, cardId, description
        },
        success(resp) {
            if (resp.success) {//如果后台保存数据成功
                if (cb) {
                    cb();//调用回调函数
                }
            }
        }
    });
}